package ILTypes;

import java.util.ArrayList;
import java.util.List;

import org.objectweb.asm.Type;

public class ILMethod {

	public boolean isPublic, isStatic;
	private int access;
	private String name;
	private String description;
	private String signature;
	private Type[] paramTypes;
	private List<String> printInstructions;
	
	public ILMethod()
	{
		printInstructions = new ArrayList<String>();
		SetFlags(0);
	}

	public ILMethod(int methAccess, String methName, String methDesc, String methSign, Type[] methParamTypes)
	{
		access = methAccess;
		name = methName;
		description = methDesc;
		signature = methSign;
		printInstructions = new ArrayList<String>();
		paramTypes = methParamTypes;
		SetFlags(methAccess);
	}
	
	private void SetFlags(int accessCode) {
		isStatic = (accessCode & 0x0008) != 0 ? true : false;
	}
	
	public int GetAccessCode() {
		return this.access;
	}
	
	public String GetName() {
		return this.name;
	}

	public String GetDescription() {
		return this.description;
	}

	public String GetSignature() {
		return this.signature;
	}
	
	public Type[] GetParameters() {
		return this.paramTypes;
	}

	public int GetParametersCount(){
		
		return paramTypes.length;
	}
	
	
	public void SetAccessCode(int accessCode) {
		this.access = accessCode;
		SetFlags(accessCode);
	}
	
	public void SetName(String methName) {
		this.name = methName;
	}

	public void SetDescription(String methDesc) {
		this.description = methDesc;
	}

	public void SetSignature(String methSign) {
		this.signature = methSign;
	}
	
	public void SetParameters(Type[] methParamTypes) {
		this.paramTypes = methParamTypes;
	}


	public List<String> GetPrintInstructions() {
		return this.printInstructions;
	}

	public void AddPrintInstructions(String ins) {
		if(ins != null)
			printInstructions.add(ins);
		return;
	}

	public void AddPrintInstructions(List<String> ins) {
		if(ins != null)
			printInstructions.addAll(ins);
		return;
	}
	
}
